/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rcnss.app.forms;

import com.rcnss.data.ITable;
import com.vaadin.data.util.BeanItem;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Form;
import com.vaadin.ui.Window;

/**
 *
 * @author Baligh GUESMI
 */
@SuppressWarnings("serial")
public class GeneralWindow extends Window implements Button.ClickListener{
    
    private Form myForm = new Form();
    private boolean _Edit;
    private Button _Close = new Button("Close", this, "buttonClickClose");
    private Button _Save = new Button("Save", this, "buttonClickSave");
    private ITable obj;
    public void setEdit(boolean _Edit) {
        this._Edit = _Edit;
    }

    public boolean isEdit() {
        return _Edit;
    }

    public GeneralWindow(Object in){
        obj = (ITable) in;
        BeanItem beanObject = new BeanItem(in);
        this.myForm.setItemDataSource(beanObject);

        this.myForm.getFooter().addComponent(this._Close);
        this.myForm.getFooter().addComponent(this._Save);

        this.addComponent(this.myForm);
    }

    public void buttonClick(ClickEvent event) {

    }

    public void buttonClickSave(ClickEvent event) {
       /* if(obj.SaveToDB()) {
        ((Window)getWindow().getParent()).showNotification("SUCCESS",
                "Informations saved",
                Window.Notification.POSITION_BOTTOM_RIGHT);
        ((Window)getWindow().getParent()).removeWindow(this);
        } else {
            getWindow().showNotification("ERROR", Window.Notification.TYPE_ERROR_MESSAGE);
        }*/
    }

    public void buttonClickClose(ClickEvent event) {

    }
}
